Skip to content

[http-client-csharp] Add SSE protocol Spector scenarios - #11921

Merged
JoshLove-msft merged 11 commits into
microsoft:mainfrom
JoshLove-msft:joshlove-msft-csharp-sse-protocol-tests
Sep 10, 2026
Merged

[http-client-csharp] Add SSE protocol Spector scenarios#11921
JoshLove-msft merged 11 commits into
microsoft:mainfrom
JoshLove-msft:joshlove-msft-csharp-sse-protocol-tests

Conversation

@JoshLove-msft

@JoshLove-msft JoshLove-msft commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Add the seven missing SSE protocol Spector tests: WithEnvelope, WithoutEnvelope, Id, InvalidId, Retry, InvalidRetry, and Reconnect. Assert exact event counts, types, and payloads, preserve valid metadata, and ignore invalid ID/retry metadata. Reconnect is explicit using RequestOptions: send Last-Event-ID from the first event, then assert resumed event 2.

The diff against main is only SseTests.cs (+109 lines). Existing JSONL and basic SSE tests are unchanged. This PR adds no generator, dependency, or TypeSpec customization changes.

#11918 has merged, and this branch is synchronized with Microsoft main at 9b8c51de8c15b6dc748ea9cf576d87f91ef058c4. It uses the pinned @typespec/http-specs 0.1.0-alpha.43 and native unique SSE model names from #11920, without the temporary naming workaround.

Validation

  • Regenerated only JSONL and SSE runtime implementations against alpha.43, then ran all 12 Streaming tests together: 12 passed, 0 failed, 0 skipped.
  • All 12 Streaming Spector coverage entries pass. Retained the TRX and coverage evidence.
  • Regenerated both libraries back to stubs. Generated files and dependency manifests match main, and no temporary C# customization or generated stub CodeGenTypeAttribute remains.
  • The main synchronization preserved the entire previously validated C# emitter tree and pinned manifests unchanged. The post-sync stubbed test-project build passed with 0 warnings and 0 errors; targeted scenario whitespace formatting, manifest formatting, and emitter lint passed. Cop checks passed on the identical C# source tree.

JoshLove-msft and others added 8 commits September 9, 2026 17:04
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Upgrade all TypeSpec and Azure toolchain dependencies and matching peer declarations to the stable September releases. Keep SSE customizations and scenario generation out of the dependency PR.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Support namespace-qualified CodeGenType mappings, preserve used customization attributes in stubs, and regenerate fixtures for the full TypeSpec upgrade. Keep streaming scenario tests in their separate PR.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Revert 422b45e from this branch; the shared model rename is maintained independently in microsoft#11920.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Merge approved dependency baseline 3d9a081 from microsoft#11918.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@11921

commit: b70a4a3

@github-actions

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new stub-library “used customization attribute” detection compares minimally-qualified Roslyn names against fully-qualified provider names, which can cause required attributes to be incorrectly dropped.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the http-client-csharp TypeSpec dependency set and expands Spector coverage for SSE “protocol” scenarios, while also enhancing the generator’s customization handling (qualified-name matching) and stub-library pruning of unused customization attributes.

Changes:

  • Bump TypeSpec/Azure Tools dependencies for http-client-csharp and refresh Spector fixture outputs accordingly.
  • Add seven missing SSE protocol Spector tests (envelope/no-envelope, id/retry validation, and reconnect via Last-Event-ID).
  • Prefer qualified CodeGenType names during customization lookups and add tests for qualified-name model/enum customization; refine stub generation to drop unused customization attribute definitions.
File summaries
File Description
packages/http-client-csharp/package.json Updates peer/dev dependency versions for the emitter toolchain.
packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/tspCodeModel.json Regenerated SSE Spector code model reflecting new protocol surface.
packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/StreamingSseModelFactory.cs Regenerated model factory with protocol model support.
packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/SseClient.cs Regenerated client to expose GetProtocolClient().
packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/ProtocolData.cs New generated protocol data client for envelope/no-envelope scenarios.
packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/Protocol.cs New generated protocol client for id/retry/reconnect scenarios.
packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/Models/StreamingSseContext.cs Registers ProtocolInfo for MRW buildable context.
packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/Models/ProtocolInfo.Serialization.cs New generated serialization for ProtocolInfo.
packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/Models/ProtocolInfo.cs New generated model type for protocol event payloads.
packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/Internal/CodeGenTypeAttribute.cs Generated customization attribute definition for fixture compilation.
packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Custom/ProtocolInfo.cs Customization to rename protocol Info to ProtocolInfo.
packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/tspCodeModel.json New/updated Spector code model for response “body or no content” fixture.
packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Response.BodyOrNoContent.csproj Adds new Spector fixture project definition.
packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/schema/ConfigurationSchema.json Adds generated configuration schema for the new fixture.
packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/ResponseBodyOrNoContentModelFactory.cs Adds generated model factory for the new fixture.
packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/Models/ResponseBodyOrNoContentContext.cs Adds MRW context for fixture models.
packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/Models/BlobLayout.Serialization.cs Adds generated serialization for BlobLayout.
packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/Models/BlobLayout.cs Adds generated model BlobLayout.
packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/BodyOrNoContentClientSettings.cs Adds generated settings type for the new fixture client.
packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/BodyOrNoContentClientOptions.cs Adds generated options type for the new fixture client.
packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/BodyOrNoContentClient.cs Adds generated client for “body or no content” operations.
packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/Response.BodyOrNoContent.slnx Adds solution entry for the new fixture.
packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/Response.BodyOrNoContent.NuGet.targets Adds targets for configuration schema packing/consumption.
packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/Configuration.json Adds generator configuration for the new fixture.
packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/Streaming/Sse/SseTests.cs Adds seven SSE protocol Spector scenarios and a single-event reader helper.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/QualifiedNameOverridesSimpleName/CustomModels.cs Test data for qualified vs simple customization precedence.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/CanRenameModelsByQualifiedNames/CustomModels.cs Test data for renaming multiple same-named models by qualified names.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/CanRenameModelByQualifiedName/ProtocolInfo.cs Test data for single qualified-name rename.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/CanRenameEnumByQualifiedName/FirstStatus.cs Test data for qualified-name enum rename.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs Adds unit tests validating qualified-name customization behavior.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/SourceInput/SourceInputModel.cs Prefers qualified CodeGenType names when resolving customization types.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Properties/launchSettings.json Adds a launch profile for the new Spector fixture.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/TestData/InputLibraryVisitorTests/StubKeepsUsedCustomizationAttributes/Model.cs Test data to ensure stub keeps attributes when directly used.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/TestData/InputLibraryVisitorTests/StubKeepsInheritedCustomizationAttributes/Model.cs Test data to ensure stub keeps base attributes for derived usage.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Microsoft.TypeSpec.Generator.ClientModel.Tests.csproj Adds stub-library project reference needed by new tests.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/InputLibraryVisitorTests.cs Adds tests verifying unused customization attributes are dropped/kept appropriately.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel.StubLibrary/src/StubLibraryVisitor.cs Implements detection of which customization attributes are used by custom code.
Review details
  • Files reviewed: 21/38 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

JoshLove-msft and others added 2 commits September 10, 2026 12:39
…on workaround

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Merge the finalized dependency upgrade with HTTP specs 0.1.0-alpha.43 and native SSE model names. Preserve the existing seven protocol scenario tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 10, 2026 19:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new WithEnvelope SSE test likely asserts the wrong payload shape and should parse/assert the JSON contents field to match the modeled event payload.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 9/25 changed files
  • Comments generated: 1
  • Review effort level: Lite

Merge Microsoft main after the dependency upgrade in microsoft#11918. Keep the PR limited to the seven SSE protocol scenario tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 10, 2026 21:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved blocking issues were identified.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@JoshLove-msft
JoshLove-msft added this pull request to the merge queue Sep 10, 2026
Merged via the queue into microsoft:main with commit b9d1cc6 Sep 10, 2026
30 checks passed
@JoshLove-msft
JoshLove-msft deleted the joshlove-msft-csharp-sse-protocol-tests branch September 10, 2026 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants